home *** CD-ROM | disk | FTP | other *** search
- Path: news2.ios.com!usenet
- From: vlad@gramercy.ios.com (Vlastimil Adamovsky)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ Gurus! Is it correct?
- Date: Sat, 03 Feb 1996 22:32:48 GMT
- Organization: Internet Online Services
- Message-ID: <4f0n8s$a3b@news2.ios.com>
- References: <4eqvtg$cg5@israel-info.datasrv.co.il> <4etnju$6gn@rolaids.frco.com>
- NNTP-Posting-Host: ppp-47.ts-7.hck.idt.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- Jadam@tcmail.frco.com (Jim Adam) wrote:
-
- >In article <4eqvtg$cg5@israel-info.datasrv.co.il>, dmitry@enigma.co.il
- >says...
-
- >>Is next code is correct from point of view of pure C++ ?
-
- >>class A
- >>{
- >>};
-
- >>class B
- >>{
- >>};
-
- >>class C : public A, public B
- >>{
- >>};
-
- >>A* pA = new C;
- >>B* pB = new C;
-
- >>delete pA;
- >>delete pB;
-
- >==========================
-
- >This is correct. However, to ensure the destructor for class
- >C gets called correctly, class A and B both need virtual
- >destructors.
-
- >E.g.,
-
- > class A
- > {
- > public:
- > virtual ~A();
- > };
-
- >And likewise for class B.
-
- >Jim
-
- I don't think the virtual destructor is necessary in this specific
- case where you have no added data in subclasses.
-
-
-
- *******************************************
- * Vlastimil Adamovsky *
- * Smalltalk, C++ and Envelop development *
- *******************************************
-
-